package edu.mis.model;
import java.util.List;

import edu.mis.model.base.BaseRole;

/**
 * 
 */
@SuppressWarnings("serial")
public class Role extends BaseRole<Role> {
	public static final Role dao=new Role();
	
	/**
	 * 查询所有权限
	 */
	public List<Role> findAll(){
		return this.find("SELECT * FROM role");
	}
	
	/**
	 * 表关联查询_得到拥有该权限的所有用户
	 * 权限:用户为1:N关系，根据1找到所有N
	 */
	public List<User> getUsers(){
		return User.dao.find("SELECT * from user WHERE roleId=?",get("id"));
	}
	
	/**
	 * 根据权限名称查询
	 */
	public Role findRoleByRoleName(String roleName) {
		return this.findFirst("select * from role where roleName=?",roleName);
	}
}